package pl.edu.agh.neuraleconomy.core.simulation;

import java.math.BigDecimal;
import java.util.Date;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import pl.edu.agh.neuraleconomy.model.exchange.Company;
import pl.edu.agh.neuraleconomy.model.simulation.Simulation;
import pl.edu.agh.neuraleconomy.model.simulation.TransactionType;

@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class Transaction extends pl.edu.agh.neuraleconomy.model.simulation.Transaction{
	
	public Transaction(pl.edu.agh.neuraleconomy.model.simulation.Transaction transaction){
		super(transaction.getType(), transaction.getCompany(), transaction.getAmount(), transaction.getDate(), transaction.getSimulation(), transaction.getPrice());
		setId(transaction.getId());
	}
	
	public Transaction(TransactionType type, Company company, int amount, Date date, Simulation simulation, BigDecimal prize){
		super(type, company, amount, date, simulation, prize);
	}
	
	private static Transaction getTransaction(TransactionType type, Company company, int amount, Date date, Simulation simulation, BigDecimal prize){
		return new Transaction(type, company, amount, date, simulation, prize);
	}
	
	public static Transaction getBuyTransaction(Company company, int amount, Date date, Simulation simulation, BigDecimal prize){
		return getTransaction(TransactionType.BUY, company, amount, date, simulation, prize);
	}
	
	public static Transaction getSellTransaction(Company company, int amount, Date date, Simulation simulation, BigDecimal prize){
		return getTransaction(TransactionType.SELL, company, amount, date, simulation, prize);
	}

}
